package cn.ycc1.storage.controller;

import cn.ycc1.storage.service.StorageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Title:
 * @Author ycc
 * @Date 2023/7/4 15:39
 */
@RestController
@RequestMapping("storage")
@Api(tags = "库存管理")
public class StorageController {

    @Autowired
    StorageService storageService;

    /**
     * 扣减库存
     * @param code 商品编号
     * @param count 要扣减的数量
     * @return 无
     */
    @PutMapping("/{code}/{count}")
    @ApiOperation(value = "扣减库存")
    public ResponseEntity<Void> deduct(@PathVariable("code") String code, @PathVariable("count") Integer count){
        storageService.deduct(code, count);
        return ResponseEntity.noContent().build();
    }
}
